package codingforgreat.lchot150;

public class Lc075 {
    public void sortColors(int[] nums) {
        int L = -1;
        int R = nums.length;
        int index = 0;
        while(index < R){
            if(nums[index] == 1){
                index++;
            }else if(nums[index] == 0){
                swap(nums,++L,index++);
            }else {
                swap(nums,--R,index);
            }
        }
    }
    public void swap(int[] nums,int i,int j){
        int temp = nums[i];
        nums[i] = nums[j];
        nums[j] = temp;
    }
}
